//
//  UserDefinedCellForSubView1ForGetJobSheet.m
//  HondaPro_2
//
//  Created by Eric on 13-6-21.
//  Copyright (c) 2013年 glendale. All rights reserved.
//

#import "UserDefinedCellForSubView1ForGetJobSheet.h"

@interface UserDefinedCellForSubView1ForGetJobSheet ()

//创建labels
-(void)initLabelsOnCell;

@end

@implementation UserDefinedCellForSubView1ForGetJobSheet

@synthesize arrForAllLabelsKeysOnCell = _arrForAllLabelsKeysOnCell;
@synthesize dicForAllLabelsOnCell = _dicForAllLabelsOnCell;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        
        [self initLabelsOnCell];
        
        self.selectionStyle = UITableViewCellSelectionStyleGray;
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark - 创建labels

-(void)initLabelsOnCell
{
    //,@"DISCOUNT"
    self.arrForAllLabelsKeysOnCell = [NSArray arrayWithObjects:
                              @"CHARGE_PARTITION_CODE",
                              @"LABOUR_CODE",
                              @"LABOUR_NAME",
                              @"STD_LABOUR_HOUR",
                              @"LABOUR_PRICE",
                              @"LABOUR_AMOUNT",nil];
    
//    NSDictionary *dicForStaticLabelsRect = [NSDictionary dictionaryWithObjectsAndKeys:
//                                            [NSValue valueWithCGRect:CGRectMake(0, 0, 70, 50)],@"CHARGE_PARTITION_CODE",
//                                            [NSValue valueWithCGRect:CGRectMake(71, 0, 210, 50)],@"LABOUR_CODE",
//                                            [NSValue valueWithCGRect:CGRectMake(281, 0, 300, 50)],@"LABOUR_NAME",
//                                            [NSValue valueWithCGRect:CGRectMake(581, 0, 100, 50)],@"STD_LABOUR_HOUR",
//                                            [NSValue valueWithCGRect:CGRectMake(681, 0, 100, 50)],@"LABOUR_PRICE",
//                                            [NSValue valueWithCGRect:CGRectMake(781, 0, 100, 50)],@"LABOUR_AMOUNT",
//                                            [NSValue valueWithCGRect:CGRectMake(881, 0, 50, 50)],@"DISCOUNT",nil];
    
    self.dicForAllLabelsOnCell = [NSMutableDictionary dictionaryWithCapacity:[_arrForAllLabelsKeysOnCell count]];
    
    for (int i = 0; i<[_arrForAllLabelsKeysOnCell count]; i++)
    {
        NSString *strKeys = [_arrForAllLabelsKeysOnCell objectAtIndex:i];
        UILabel *lbl = [[UILabel alloc] init];
        lbl.backgroundColor = [UIColor clearColor];
        lbl.textColor = [UIColor grayColor];
        lbl.font = [UIFont fontWithName:@"ArialMT" size:16];
        lbl.numberOfLines = 2;
        [self.dicForAllLabelsOnCell setObject:lbl forKey:strKeys];
        [self.contentView addSubview:lbl];
        
        lbl.numberOfLines = 2;
        
//        if (0 == i)
//        {
            lbl.textAlignment = NSTextAlignmentCenter;
//        }
    }
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat w=self.bounds.size.width/[_arrForAllLabelsKeysOnCell count];
    int i =0;
    for (UILabel*label in self.contentView.subviews) {
        label.frame = CGRectMake(i*w, 0, w, 50);
        i++;
    }
}
@end
